<?php

/*   Description  of this file
 *    Author king-of-war
 *    Last Modified 2009-5-6
 *    This class designed  for the friend link operation
 */
 @session_start();
 $root_path='../';
 include_once $root_path.'admin/smarty_config.php';
include_once $root_path.'admin/class/flink.class.php';
include_once $root_path.'admin/class/verify.class.php';
include_once $root_path.'admin/class/error.class.php';
/*
 *
 * check identify
 */
include_once $root_path.'admin/class/verify.class.php';
$a=new verify($root_path);
$a->identity_check(3);



$error=new Errmsg();


 $flink=new flink($root_path);
/*
 * get date with id
 *
 * check the id which has been choosed or none
 */
if($_GET['id']!=''){
$id=$_GET['id'];
}else{
$info='请选择要编辑的友情链接';
$error->error_chinese($info);
exit;
}
/*
 *   get all info from database with the id
 *
 * 1 as administrator
 */
 $pass=$flink->flink_get($id,1);

 $links['id']=$pass[0]->get_id();
 $links['name']=$pass[0]->get_name();
 $links['images']=$pass[0]->get_images();
 $links['introduction']=$pass[0]->get_introduction();
 $links['url']=$pass[0]->get_url();
 $links['verify']=$pass[0]->get_verify();


/*
 *get Post data &&  flink add
 */


$info = '友情链接更新';
if(isset($_POST['submit'])){
	$name=$_POST['name'];
	$image=$_POST['image'];
	$introduction=$_POST['introduction'];
	$url=$_POST['url'];
	$verify=$_POST['verify'];

/*
 * $fun: 2 for update
 */
$bool= $flink->flink_add($id,$name,$image,$introduction,$url,$verify,2) ;
if($bool){
	$info= '更新成功';
}else{
	$info= '更新失败';
}
}
 /*
 * set the template for flink.php
 */
$smarty->assign("flink",$links);
$smarty->assign("state",$info);
$smarty->display("flink_update.html");



?>
